package com.example.validproject.exception;

import com.example.validproject.protocol.BaseErrorCode;
import com.example.validproject.protocol.IErrorCode;

/**
 * @author kh
 * Created by on  2021-09-27 10:47
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = -446784802285331881L;

    private IErrorCode errorCode = BaseErrorCode.INTERNAL_SERVER_ERROR;

    public BusinessException(IErrorCode code, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = code;
    }

    public BusinessException(IErrorCode code, Throwable cause) {
        super(code.getMessage(), cause);
        this.errorCode = code;
    }

    public BusinessException(IErrorCode code, String message) {
        super(message);
        this.errorCode = code;
    }

    public BusinessException(IErrorCode code) {
        super(code.getMessage());
        this.errorCode = code;
    }

    public BusinessException(String message) {
        super(message);
    }

    //    public BusinessException(int code) {
    //        this.errorCode = BaseErrorCode.getByCode(code);
    //    }

    public IErrorCode getErrorCode() {
        return errorCode;
    }
}
